package GUI;
import java.util.LinkedList;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;

import Conf.Consts;
import DB.DBCharacterConnector;
import DB.DBConnector;
import DB.DBSettingConnector;
import DB.DBSpeciesConnector;
import Entities.GameCharacter;
import Entities.GameSetting;
import Entities.GameSpecies;
import Game.IGameInfo;
import Logic.Objects.GameOptions;
import Logic.Objects.GameOptions.Aggression;
import Logic.Objects.GameOptions.Blitzkrieg;
import Logic.Objects.GameOptions.BoardVisibility;
import Logic.Objects.GameOptions.BombsExplosion;
import Logic.Objects.GameOptions.BombsReuse;
import Logic.Objects.GameOptions.FlagCapture;
import Logic.Objects.GameOptions.MovableFlag;
import Logic.Objects.GameOptions.VisibleFlag;
import com.cloudgarden.resource.SWTResourceManager;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class exGUI extends org.eclipse.swt.widgets.Composite {

	public boolean Result; 
	private Canvas canvas3;
	private Label label2;
	private Label label1;
	private Label label11;
	private Label label18;
	private Label label17;
	private Label label16;
	private Button btnNextCharacter;
	private Button btnPrevCharacter;
	private Button btnNextSpecies;
	private Button btnPrevSpecies;
	private Button btnNextSetting;
	private Button btnPrevSetting;
	private Combo combo5;
	private Browser browser1;
	private Label label20;
	private Label label15;
	private Label label14;
	private Label label13;
	private List selectedTribeList;
	private Canvas canvas4;
	private List characterList;
	private List speciesList;
	private List worldList;
	private Canvas canvas6;
	private Canvas canvas2;
	private Canvas canvas1;
	private Combo combo9;
	private Combo combo8;
	private Combo combo7;
	private Combo combo6;
	private Combo combo4;
	private Combo combo3;
	private Combo combo2;
	private Combo combo1;
	private Label label12;
	private Label label10;
	private Label label9;
	private Label label8;
	private Label label7;
	private Label label6;
	private Label label5;
	private Button button1;
	private Text text2;
	private Text textnAI;
	private Text textnPlayers;
	private Label label4;
	private Label label3;
	private MainGui maingui;
	private int modeFlag;
	TableItem item;
	IGameInfo gameInfo;
	int currentNum;
	int maxNum ;
	LinkedList<GameSetting> tempsettingList;
	LinkedList<GameSpecies> tempspeciesList;
	LinkedList<GameCharacter> tempcharacterList,selectedCharacterList=new LinkedList<GameCharacter>();
	int speciesPos=0,characterPos=0,worldPos=0;

	{
		SWTResourceManager.registerResourceUser(this);
	}

	public exGUI(Composite parent, int style, MainGui maingui1,int modeFlag1) {
		super(parent, style);
		modeFlag=modeFlag1;
		maingui=maingui1;
		Result =false;
		initGUI();
	}

	private void initGUI() {
		this.setSize(1127, 521);
		this.setBackground(SWTResourceManager.getColor(48, 48, 48));
		FormLayout thisLayout = new FormLayout();
		this.setLayout(thisLayout);
		{
			label13 = new Label(this, SWT.NONE);
			FormData label13LData = new FormData();
			label13LData.left =  new FormAttachment(0, 1000, 12);
			label13LData.top =  new FormAttachment(0, 1000, 12);
			label13LData.width = 289;
			label13LData.height = 16;
			label13.setLayoutData(label13LData);
			label13.setText("(1) Choose Game Options:");
		}
		{
			FormData canvas2LData = new FormData();
			canvas2LData.left =  new FormAttachment(0, 1000, 313);
			canvas2LData.top =  new FormAttachment(0, 1000, 34);
			canvas2LData.width = 374;
			canvas2LData.height = 202;
			canvas2 = new Canvas(this, SWT.NONE);
			canvas2.setLayoutData(canvas2LData);
			canvas2.setBackground(SWTResourceManager.getColor(65, 65, 65));
			{
				worldList = new List(canvas2, SWT.NONE);
				worldList.setBounds(42, 15, 266, 154);
				worldList.setBackground(SWTResourceManager.getColor(95, 95, 95));
				worldList.setForeground(SWTResourceManager.getColor(255, 255, 255));
				worldList.addSelectionListener(new SelectionAdapter() {
					public void widgetSelected(SelectionEvent evt) {
						worldListWidgetSelected(evt);
					}
				});
			}
			{
				btnPrevSetting = new Button(canvas2, SWT.PUSH | SWT.CENTER);
				btnPrevSetting.setText("<<");
				btnPrevSetting.setBounds(42, 169, 60, 13);
				btnPrevSetting.addMouseListener(new MouseAdapter() {
					public void mouseDown(MouseEvent evt) {
						btnPrevSettingMouseDown(evt);
					}
				});
			}
			{
				btnNextSetting = new Button(canvas2, SWT.PUSH | SWT.CENTER);
				btnNextSetting.setText(">>");
				btnNextSetting.setBounds(248, 169, 60, 13);
				btnNextSetting.addMouseListener(new MouseAdapter() {
					public void mouseDown(MouseEvent evt) {
						btnNextSettingMouseDown(evt);
					}
				});
			}
			{
				label20 = new Label(canvas2, SWT.NONE);
				label20.setText("Arenas:");
				label20.setBounds(152, 0, 60, 30);
				label20.setForeground(SWTResourceManager.getColor(255, 255, 255));
				label20.setBackground(SWTResourceManager.getColor(65, 65, 65));
			}
		}
		{
			FormData canvas1LData = new FormData();
			canvas1LData.left =  new FormAttachment(0, 1000, 70);
			canvas1LData.top =  new FormAttachment(0, 1000, 378);
			canvas1LData.width = 104;
			canvas1LData.height = 101;
			canvas1 = new Canvas(this, SWT.NONE);
			canvas1.setLayoutData(canvas1LData);
			canvas1.setBackgroundImage(SWTResourceManager.getImage("Resources/skull2.jpg"));
		}
		{
			canvas3 = new Canvas(this, SWT.NONE);
			FormData canvas3LData = new FormData();
			canvas3LData.width = 289;
			canvas3LData.height = 332;
			canvas3LData.left =  new FormAttachment(0, 1000, 12);
			canvas3LData.top =  new FormAttachment(0, 1000, 34);
			canvas3.setLayoutData(canvas3LData);
			canvas3.setBackground(SWTResourceManager.getColor(65, 65, 65));
			{
				label2 = new Label(canvas3, SWT.NONE);
				label2.setText("Game Name");
				label2.setBounds(12, 12, 95, 20);
				label2.setBackground(SWTResourceManager.getColor(65, 65, 65));
				label2.setFont(SWTResourceManager.getFont("Arial", 9, 3, false, false));
				label2.setForeground(SWTResourceManager.getColor(255, 255, 255));
			}
			{
				label3 = new Label(canvas3, SWT.NONE);
				label3.setText("Num of Players");
				label3.setBounds(12, 38, 87, 15);
				label3.setBackground(SWTResourceManager.getColor(65, 65, 65));
				label3.setFont(SWTResourceManager.getFont("Arial", 9, 3, false, false));
				label3.setForeground(SWTResourceManager.getColor(255, 255, 255));
			}
			{
				label4 = new Label(canvas3, SWT.NONE);
				label4.setText("Num of AIs");
				label4.setBounds(12, 62, 81, 15);
				label4.setBackground(SWTResourceManager.getColor(65, 65, 65));
				label4.setFont(SWTResourceManager.getFont("Arial", 9, 3, false, false));
				label4.setForeground(SWTResourceManager.getColor(255, 255, 255));
			}
			{
				textnPlayers = new Text(canvas3, SWT.NONE);
				textnPlayers.setText("2");
				textnPlayers.setBounds(134, 36, 29, 18);
			}
			{
				textnAI = new Text(canvas3, SWT.NONE);
				textnAI.setText("1");
				textnAI.setBounds(134, 60, 29, 16);
			}
			{
				text2 = new Text(canvas3, SWT.NONE);
				text2.setText("Demo");
				text2.setBounds(134, 10, 89, 19);
			}
			{
				label1 = new Label(canvas3, SWT.NONE);
				label1.setText("Aggression");
				label1.setBounds(12, 87, 66, 15);
				label1.setBackground(SWTResourceManager.getColor(65, 65, 65));
				label1.setFont(SWTResourceManager.getFont("Arial", 9, 3, false, false));
				label1.setForeground(SWTResourceManager.getColor(255, 255, 255));
			}
			{
				label5 = new Label(canvas3, SWT.NONE);
				label5.setText("Bombs Reuse");
				label5.setBounds(12, 114, 74, 15);
				label5.setBackground(SWTResourceManager.getColor(65, 65, 65));
				label5.setFont(SWTResourceManager.getFont("Arial", 9, 3, false, false));
				label5.setForeground(SWTResourceManager.getColor(255, 255, 255));
			}
			{
				label6 = new Label(canvas3, SWT.NONE);
				label6.setText("Bombs Explosion");
				label6.setBounds(12, 143, 101, 15);
				label6.setBackground(SWTResourceManager.getColor(65, 65, 65));
				label6.setFont(SWTResourceManager.getFont("Arial", 9, 3, false, false));
				label6.setForeground(SWTResourceManager.getColor(255, 255, 255));
			}
			{
				label7 = new Label(canvas3, SWT.NONE);
				label7.setText("Soldiers Visibility");
				label7.setBounds(12, 171, 101, 15);
				label7.setBackground(SWTResourceManager.getColor(65, 65, 65));
				label7.setFont(SWTResourceManager.getFont("Arial", 9, 3, false, false));
				label7.setForeground(SWTResourceManager.getColor(255, 255, 255));
			}
			{
				label8 = new Label(canvas3, SWT.NONE);
				label8.setText("Combat Results");
				label8.setBounds(12, 198, 95, 15);
				label8.setBackground(SWTResourceManager.getColor(65, 65, 65));
				label8.setFont(SWTResourceManager.getFont("Arial", 9, 3, false, false));
				label8.setForeground(SWTResourceManager.getColor(255, 255, 255));
			}
			{
				label9 = new Label(canvas3, SWT.NONE);
				label9.setText("Blitzkrieg");
				label9.setBounds(12, 225, 60, 15);
				label9.setBackground(SWTResourceManager.getColor(65, 65, 65));
				label9.setFont(SWTResourceManager.getFont("Arial", 9, 3, false, false));
				label9.setForeground(SWTResourceManager.getColor(255, 255, 255));
			}
			{
				label10 = new Label(canvas3, SWT.NONE);
				label10.setText("Visible Flags");
				label10.setBounds(12, 253, 74, 15);
				label10.setBackground(SWTResourceManager.getColor(65, 65, 65));
				label10.setFont(SWTResourceManager.getFont("Arial", 9, 3, false, false));
				label10.setForeground(SWTResourceManager.getColor(255, 255, 255));
			}
			{
				label11 = new Label(canvas3, SWT.NONE);
				label11.setText("Moveable Flags");
				label11.setBounds(12, 282, 95, 15);
				label11.setBackground(SWTResourceManager.getColor(65, 65, 65));
				label11.setFont(SWTResourceManager.getFont("Arial", 9, 3, false, false));
				label11.setForeground(SWTResourceManager.getColor(255, 255, 255));
			}
			{
				label12 = new Label(canvas3, SWT.NONE);
				label12.setText("Flag Capture");
				label12.setBounds(12, 308, 74, 15);
				label12.setBackground(SWTResourceManager.getColor(65, 65, 65));
				label12.setFont(SWTResourceManager.getFont("Arial", 9, 3, false, false));
				label12.setForeground(SWTResourceManager.getColor(255, 255, 255));
			}
			{
				combo1 = new Combo(canvas3, SWT.NONE);
				combo1.setBounds(134, 81, 140, 23);
				combo1.setItems(new java.lang.String[] {"On tie both die","On tie attacker wins"});
				combo1.select(0);
			}
			{
				combo2 = new Combo(canvas3, SWT.NONE);
				combo2.setBounds(134, 108, 140, 23);
				combo2.setItems(new java.lang.String[] {"Multiple explosions","One-time bomb"});
				combo2.select(0);
			}
			{
				combo3 = new Combo(canvas3, SWT.NONE);
				combo3.setBounds(134, 137, 140, 23);
				combo3.setItems(new java.lang.String[] {"Regular radius","Big radius"});
				combo3.select(0);
			}
			{
				combo4 = new Combo(canvas3, SWT.NONE);
				combo4.setBounds(134, 166, 140, 23);
				combo4.setItems(new java.lang.String[] {"See only my soldiers","See all soldiers"});
				combo4.select(0);

				combo4.addSelectionListener(new SelectionListener() {
					public void widgetSelected(SelectionEvent evt) {
						if(combo4.getSelectionIndex()==1)
							combo7.setEnabled(false);
						else
							combo7.setEnabled(true);
					}

					@Override
					public void widgetDefaultSelected(SelectionEvent arg0) {
					}
				} );

			}
			{
				combo5 = new Combo(canvas3, SWT.NONE);
				combo5.setBounds(134, 193, 140, 23);
				combo5.setItems(new java.lang.String[] {"Everybody see","Only fighters"});
				combo5.select(0);
			}
			{

				combo6 = new Combo(canvas3, SWT.NONE);
				combo6.setBounds(134, 221, 140, 23);
				combo6.setItems(new java.lang.String[] {"Off","On"});
				combo6.select(0);


			}
			{
				combo7 = new Combo(canvas3, SWT.NONE);
				combo7.setBounds(134, 248, 140, 23);
				combo7.setItems(new java.lang.String[] {"Off","On"});
				combo7.select(0);
			}
			{
				combo8 = new Combo(canvas3, SWT.NONE);
				combo8.setBounds(134, 276, 140, 23);
				combo8.setItems(new java.lang.String[] {"Off","On"});
				combo8.select(0);
			}
			{
				combo9 = new Combo(canvas3, SWT.NONE);
				combo9.setBounds(134, 302, 140, 23);
				combo9.setItems(new java.lang.String[] {"Losing soldiers die","Losing soldiers change team"});
				combo9.select(0);
			}
		}
		{
			button1 = new Button(this, SWT.PUSH | SWT.CENTER);
			button1.setText("Start!");
			button1.setBackground(SWTResourceManager.getColor(48, 48, 48));
			FormData button1LData = new FormData();
			button1LData.width = 171;
			button1LData.height = 25;
			button1LData.left =  new FormAttachment(0, 1000, 38);
			button1LData.top =  new FormAttachment(0, 1000, 491);
			button1.setLayoutData(button1LData);
			button1.setEnabled(false);
			button1.addMouseListener(new MouseAdapter() {
				public void mouseDown(MouseEvent evt) {
					button1MouseDown(evt);
				}
			});
		}
		{
			FormData canvas6LData = new FormData();
			canvas6LData.left =  new FormAttachment(0, 1000, 697);
			canvas6LData.top =  new FormAttachment(0, 1000, 34);
			canvas6LData.width = 424;
			canvas6LData.height = 474;
			canvas6 = new Canvas(this, SWT.NONE);
			canvas6.setLayoutData(canvas6LData);
			canvas6.setBackground(SWTResourceManager.getColor(65, 65, 65));
			{
				speciesList = new List(canvas6, SWT.NONE);
				speciesList.setBounds(122, 16, 196, 199);
				speciesList.setBackground(SWTResourceManager.getColor(95, 95, 95));
				speciesList.setForeground(SWTResourceManager.getColor(255, 255, 255));
				speciesList.addSelectionListener(new SelectionAdapter() {
					public void widgetSelected(SelectionEvent evt) {
						speciesListWidgetSelected(evt);
					}
				});
			}
			{
				characterList = new List(canvas6, SWT.NONE);
				characterList.setBounds(12, 257, 196, 192);
				characterList.setBackground(SWTResourceManager.getColor(95, 95, 95));
				characterList.setForeground(SWTResourceManager.getColor(255, 255, 255));
				characterList.addMouseListener(new MouseAdapter() {
					public void mouseDoubleClick(MouseEvent evt) {
						characterListMouseDoubleClick(evt);
					}
				});
				characterList.addSelectionListener(new SelectionAdapter() {
					public void widgetSelected(SelectionEvent evt) {
						characterListWidgetSelected(evt);
					}
				});
			}
			{
				selectedTribeList = new List(canvas6, SWT.NONE);
				selectedTribeList.setBounds(220, 257, 197, 192);
				selectedTribeList.setBackground(SWTResourceManager.getColor(35, 35, 35));
				selectedTribeList.setForeground(SWTResourceManager.getColor(255, 255, 255));
				selectedTribeList.addMouseListener(new MouseAdapter() {
					public void mouseDoubleClick(MouseEvent evt) {
						selectedTribeListMouseDoubleClick(evt);
					}
				});
			}
			{
				btnPrevSpecies = new Button(canvas6, SWT.PUSH | SWT.CENTER);
				btnPrevSpecies.setText("<<");
				btnPrevSpecies.setBounds(122, 215, 60, 14);
				btnPrevSpecies.addMouseListener(new MouseAdapter() {
					public void mouseDown(MouseEvent evt) {
						btnPrevSpeciesMouseDown(evt);
					}
				});
			}
			{
				btnNextSpecies = new Button(canvas6, SWT.PUSH | SWT.CENTER);
				btnNextSpecies.setText(">>");
				btnNextSpecies.setBounds(258, 215, 60, 14);
				btnNextSpecies.addMouseListener(new MouseAdapter() {
					public void mouseDown(MouseEvent evt) {
						btnNextSpeciesMouseDown(evt);
					}
				});
			}
			{
				btnPrevCharacter = new Button(canvas6, SWT.PUSH | SWT.CENTER);
				btnPrevCharacter.setText("<<");
				btnPrevCharacter.setBounds(12, 449, 60, 16);
				btnPrevCharacter.addMouseListener(new MouseAdapter() {
					public void mouseDown(MouseEvent evt) {
						btnPrevCharacterMouseDown(evt);
					}
				});
			}
			{
				btnNextCharacter = new Button(canvas6, SWT.PUSH | SWT.CENTER);
				btnNextCharacter.setText(">>");
				btnNextCharacter.setBounds(148, 449, 60, 16);
				btnNextCharacter.addMouseListener(new MouseAdapter() {
					public void mouseDown(MouseEvent evt) {
						btnNextCharacterMouseDown(evt);
					}
				});
			}
			{
				label16 = new Label(canvas6, SWT.NONE);
				label16.setText("Chosen Tribe:");
				label16.setBounds(274, 241, 82, 17);
				label16.setBackground(SWTResourceManager.getColor(65, 65, 65));
				label16.setForeground(SWTResourceManager.getColor(255, 255, 255));
			}
			{
				label17 = new Label(canvas6, SWT.NONE);
				label17.setText("Species:");
				label17.setBounds(189, 2, 51, 30);
				label17.setBackground(SWTResourceManager.getColor(65, 65, 65));
				label17.setForeground(SWTResourceManager.getColor(255, 255, 255));
			}
			{
				label18 = new Label(canvas6, SWT.NONE);
				label18.setText("Characters:");
				label18.setBounds(72, 241, 66, 30);
				label18.setBackground(SWTResourceManager.getColor(65, 65, 65));
				label18.setForeground(SWTResourceManager.getColor(255, 255, 255));
			}
		}
		{
			canvas4 = new Canvas(this, SWT.NONE);
			FormData canvas4LData = new FormData();
			canvas4LData.left =  new FormAttachment(0, 1000, 307);
			canvas4LData.top =  new FormAttachment(0, 1000, 248);
			canvas4LData.width = 192;
			canvas4LData.height = 200;
			canvas4.setLayoutData(canvas4LData);
			canvas4.setBackground(SWTResourceManager.getColor(65,65,65));
			{
				browser1 = new Browser(canvas4, SWT.NONE);
				browser1.setBounds(6, 12, 207, 208);
			}
		}
		{
			label14 = new Label(this, SWT.NONE);
			label14.setText("(2) Choose Game Arena");
			FormData label14LData = new FormData();
			label14LData.left =  new FormAttachment(0, 1000, 313);
			label14LData.top =  new FormAttachment(0, 1000, 12);
			label14LData.width = 374;
			label14LData.height = 16;
			label14.setLayoutData(label14LData);
		}
		{
			label15 = new Label(this, SWT.NONE);
			label15.setText("(3) Choose Your Tribe:");
			FormData label15LData = new FormData();
			label15LData.left =  new FormAttachment(0, 1000, 699);
			label15LData.top =  new FormAttachment(0, 1000, 12);
			label15LData.width = 422;
			label15LData.height = 16;
			label15.setLayoutData(label15LData);
		}
		this.layout();
	}

	private void button1MouseDown(MouseEvent evt) {
		Result = true;
		switch (modeFlag)
		{
		case 0:
			maingui.GameName=text2.getText();
			maingui.nPlayers=Integer.valueOf(textnPlayers.getText()).intValue();			
			maingui.nAI=Integer.valueOf(textnAI.getText()).intValue();
			maingui.gameOptions=new GameOptions();
			maingui.gameOptions.setAggression(Aggression.values()[combo1.getSelectionIndex()]);
			maingui.gameOptions.setBombReuse(BombsReuse.values()[combo2.getSelectionIndex()]);
			maingui.gameOptions.setBombsExplosion(BombsExplosion.values()[combo3.getSelectionIndex()]);
			maingui.gameOptions.setBoardVisibility(BoardVisibility.values()[combo4.getSelectionIndex()]);
			maingui.gameOptions.setBlitzkrieg(Blitzkrieg.values()[combo6.getSelectionIndex()]);
			maingui.gameOptions.setVisibleFlag(VisibleFlag.values()[combo7.getSelectionIndex()]);
			maingui.gameOptions.setMovableFlag(MovableFlag.values()[combo8.getSelectionIndex()]);
			maingui.gameOptions.setFlagCapture(FlagCapture.values()[combo9.getSelectionIndex()]);
			break;
		}
		this.getShell().close();
	}
	
	public void loadForm(Object param){
		new Thread(){public void run(){
			final LinkedList<GameSetting> list2=DBSettingConnector.getSettingList(0,true);
			final LinkedList<GameSpecies> list=DBSpeciesConnector.getSpeciesList(0,true);
			Display.getDefault().asyncExec(new Runnable(){
		        public void run(){
		        	putSettingData(list2);
		        	putSpeciesData(list);
		        }});
		}}.start();
	}
	
	private void worldListWidgetSelected(SelectionEvent evt) {
		int index=worldList.getSelectionIndex();
		if (index!=-1){
			GameSetting tempSetting=tempsettingList.get(index);
			browser1.setUrl(DBConnector.freeBaseImageURL+tempSetting.getfreeBaseID());
		}
	}
	
	private void characterListWidgetSelected(SelectionEvent evt) {
		int index=characterList.getSelectionIndex();
		if (index!=-1){
			GameCharacter tempCharacter=tempcharacterList.get(index);
			browser1.setUrl(DBConnector.freeBaseImageURL+tempCharacter.getfreeBaseID());
		}
	}

	private void speciesListWidgetSelected(SelectionEvent evt) {
		int index=speciesList.getSelectionIndex();
		if (index!=-1){
			final GameSpecies tempSpecies=tempspeciesList.get(index);
			browser1.setUrl(DBConnector.freeBaseImageURL+tempSpecies.getfreeBaseID());
			new Thread(){public void run(){
				final LinkedList<GameCharacter> list=DBCharacterConnector.getCharacterList(0,tempSpecies.getID());
				Display.getDefault().asyncExec(new Runnable(){
			        public void run(){
			        	putCharacterData(list);
			        }});
			}}.start();
		}
	}
	
	private void characterListMouseDoubleClick(MouseEvent evt) {
		int index=characterList.getSelectionIndex();
		if (selectedCharacterList.size()<Consts.NumOfSquersPerPlayer){
			if (index!=-1){
				GameCharacter selectedCharacter=tempcharacterList.get(index);
				if (!selectedCharacterList.contains(selectedCharacter)){//can't select same character twice
					selectedCharacterList.add(selectedCharacter);
					selectedTribeList.add(selectedCharacter.getName());
					if (selectedCharacterList.size()==Consts.NumOfSquersPerPlayer)	
						button1.setEnabled(true);
				}
			}
		}
	}
	
	private void selectedTribeListMouseDoubleClick(MouseEvent evt) {
		int index=selectedTribeList.getSelectionIndex();
		if (index!=-1){
			selectedCharacterList.remove(index);
			selectedTribeList.remove(index);
			button1.setEnabled(false);
		}
	}
	
	public void putSpeciesData(LinkedList<GameSpecies> list){
		tempspeciesList=list;
		speciesList.removeAll();
		for (GameSpecies species:tempspeciesList)
			speciesList.add(species.getName());
	}
	
	public void putCharacterData(LinkedList<GameCharacter> list){
		tempcharacterList=list;
		characterList.removeAll();
		for (GameCharacter species:tempcharacterList)
			characterList.add(species.getName());
	}
	
	public void putSettingData(LinkedList<GameSetting> list){
		tempsettingList=list;
		worldList.removeAll();
		for (GameSetting species:tempsettingList)
			worldList.add(species.getName());
	}
	
	private void btnNextSettingMouseDown(MouseEvent evt) {
		worldPos=tempsettingList.getLast().getID();
		new Thread(){public void run(){
			final LinkedList<GameSetting> list=DBSettingConnector.getSettingList(worldPos,true);
			Display.getDefault().asyncExec(new Runnable(){
		        public void run(){
		        	putSettingData(list);
		        }});
		}}.start();
	}
	
	private void btnNextSpeciesMouseDown(MouseEvent evt) {
		speciesPos=tempspeciesList.getLast().getID();
		new Thread(){public void run(){
			final LinkedList<GameSpecies> list=DBSpeciesConnector.getSpeciesList(speciesPos,true);
			Display.getDefault().asyncExec(new Runnable(){
		        public void run(){
		        	putSpeciesData(list);
		        }});
		}}.start();
	}
	
	private void btnNextCharacterMouseDown(MouseEvent evt) {
	/*	characterPos=tempsettingList.getLast().getID();
		new Thread(){public void run(){
			final LinkedList<GameCharacter> list=IlanDBConnector.getCharacterList(characterPos,true);
			Display.getDefault().asyncExec(new Runnable(){
		        public void run(){
		        	putCharacterData(list);
		        }});
		}}.start();
	*/}
	
	private void btnPrevSettingMouseDown(MouseEvent evt) {
		worldPos=tempsettingList.getFirst().getID();
		new Thread(){public void run(){
			final LinkedList<GameSetting> list=DBSettingConnector.getSettingList(worldPos,false);
			Display.getDefault().asyncExec(new Runnable(){
		        public void run(){
		        	putSettingData(list);
		        }});
		}}.start();
	}
	
	private void btnPrevSpeciesMouseDown(MouseEvent evt) {
		speciesPos=tempspeciesList.getFirst().getID();
		new Thread(){public void run(){
			final LinkedList<GameSpecies> list=DBSpeciesConnector.getSpeciesList(speciesPos,false);
			Display.getDefault().asyncExec(new Runnable(){
		        public void run(){
		        	putSpeciesData(list);
		        }});
		}}.start();
	}
	
	private void btnPrevCharacterMouseDown(MouseEvent evt) {
	/*	characterPos=tempsettingList.getFirst().getID();
		new Thread(){public void run(){
			final LinkedList<GameCharacter> list=IlanDBConnector.getCharacterList(characterPos,false);
			Display.getDefault().asyncExec(new Runnable(){
		        public void run(){
		        	putCharacterData(list);
		        }});
		}}.start();
	*/}
}